package com.xiaoy;



import org.eclipse.jetty.server.Server;


/**
 * Main Class for standalone running.
 * 
 * @author calvin
 */
public class StartMain {

	public static final int		PORT		= 9998;
	public static final String	CONTEXT		= "/workspace";//"/kingdoms.workspace"   "/workspace";
	public static final String	BASE_URL	= "http://cty:"+PORT+CONTEXT+"/workspace/index.do";
	
	public static void start () {
		// 设定Spring的profile
		System.setProperty("spring.profiles.active", "development");

		// 启动Jettyz
		Server server = JettyFactory.createServerInSource(PORT, CONTEXT);
		// JettyFactory.setTldJarNames(server, TLD_JAR_NAMES);

		try {
			server.start();
			System.out.println("Server running at " + BASE_URL);
			Runtime.getRuntime().exec("E:/Program Files/Mozilla Firefox/firefox.exe /c start " + BASE_URL);
			System.out.println("Hit Enter to reload the application");
			// 等待用户输入回车重载应用.
			while (true) {
				char c = (char) System.in.read();
				if (c == '\n') {
					JettyFactory.reloadContext(server);
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}
	
	public static void main(String[] args) {
		try {
			start ();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
}
